#$Id: PKGBUILD 85352 2013-03-01 10:31:59Z andrea $
# Maintainer: Alexander Rødseth <rodseth@gmail.com>
# Contributor: spambanane <happy.house@gmx.de>
# Contributor: Matteo <matteo.dek@gmail.com>

pkgname=golangide
pkgver=17
pkgrel=2
pkgdesc='IDE for editing and building projects written in the Go programming language (now LiteIDE X)'
license=('LGPL')
arch=('x86_64' 'i686')
url='https://github.com/visualfc/liteide'
depends=('go' 'libpng12' 'glib2' 'qt4' 'qjson')
makedepends=('gendesk')
options=('!strip')
_name=('Golang IDE')
# http://$pkgname.googlecode.com/files/liteidex$pkgver.linux-386-webkit.tar.bz2
# http://$pkgname.googlecode.com/files/liteidex$pkgver.linux-amd64-webkit.tar.bz2
source=("$pkgname.tgz::https://nodeload.github.com/visualfc/liteide/tar.gz/master"
        'golangide.png'
        'golangide.sh')
sha256sums=('88fae4a43a82ecb12739bfe6612d736fa963d8beaf30dccfb305c335929c3871'
            '47c52b22326034bd3d6a7b11b05a53c8b3838c08e145171cf5cad2ca00260697'
            'aa5ea27f9c3626431a9cb45e5267771a1eeff48b2e3927c0574eaef9302cfd74')

build() {
  cd "$srcdir"
  msg2 'Generating .desktop file...'
  gendesk -n

  msg2 'Compiling...'
  cd liteide-master/build
  chmod +x build_linux.sh webkit_linux.sh
  QTDIR=/usr ./build_linux.sh
  QTDIR=/usr ./webkit_linux.sh

  # Fixing insecure RPATH, need to test if this is still needed
  msg2 'Fixing...'
  cd ../liteidex
  find . -name "*.so" -type f -exec sed -i 's|/home/win|/usr/lib/|g' {} \;
  find . -name liteide -type f -exec sed -i 's|/home/win|/usr/lib/|g' {} \;
}

package() {
  msg2 'Creating directories...'
  mkdir -p "$pkgdir/usr/lib/liteide"
  mkdir -p "$pkgdir/usr/share/liteide"
  mkdir -p "$pkgdir/usr/share/doc/$pkgname"

  cd "$srcdir/liteide-master/build/liteide"

  msg2 'Packaging executables...'
  for binary in goastview goapi goexec godocview liteide; do
    install -Dm755 "bin/$binary" "$pkgdir/usr/bin/$binary"
  done
  install -Dm755 "$srcdir/$pkgname.sh" "$pkgdir/usr/bin/$pkgname"

  cd "$srcdir/liteide-master/liteidex"

  msg2 'Packaging resources...'
  cp -r deploy/* "$pkgdir/usr/share/liteide"
  cp -r os_deploy/* "$pkgdir/usr/share/liteide"

  msg2 'Packaging libraries and plugins...'
  cp -r liteide/lib/liteide/* "$pkgdir/usr/lib/liteide"
  cp -r liteide/bin/libliteapp.* "$pkgdir/usr/lib/"
  chmod -x "$pkgdir/usr/lib/liteide/plugins/"*

  msg2 'Packaging license and license exception...'
  install -Dm644 LICENSE.LGPL \
    "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
  install -Dm644 LGPL_EXCEPTION.TXT \
    "$pkgdir/usr/share/licenses/$pkgname/LGPL_EXCEPTION"

  cd ../..

  msg2 'Packaging menu entry and icon...'
  install -Dm644 "$pkgname.desktop" \
    "$pkgdir/usr/share/applications/$pkgname.desktop"
  install -Dm644 "$pkgname.png" \
    "$pkgdir/usr/share/pixmaps/$pkgname.png"

  msg2 'Cleaning up...'
  rm -rf "$pkgdir/usr/share/$pkgname/doc"
}

# vim:set ts=2 sw=2 et:
